import json

def convert_wubi_to_json(input_file, output_file):
    # 读取原始文件
    with open(input_file, 'r', encoding='utf-8') as f:
        lines = f.readlines()
    
    # 创建结果字典
    result = {}
    
    for line in lines:
        # 分割每行的编码和汉字
        parts = line.strip().split()
        if len(parts) >= 2:
            code = parts[0]
            char = parts[1]
            
            # 创建对应的JSON结构
            result[char] = {
                "prefix": code,
                "description": "",
                "body": [char]
            }
    
    # 写入输出文件
    with open(output_file, 'w', encoding='utf-8') as f:
        json.dump(result, f, ensure_ascii=False, indent=4)

# 使用示例
input_file = 'wubiSingle.txt'
output_file = 'output.json'
convert_wubi_to_json(input_file, output_file)
